package fr.poy.mygluco.client.gxt;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.widget.Status;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.rpc.StatusCodeException;

import fr.poy.mygluco.client.ui.MessageHandler;

public abstract class AppAsyncCallback<T> extends BaseAsyncCallback<T> {
	 
 
	public AppAsyncCallback() {
		((Status)Registry.get("status")).setBusy("patientez...");
	}

	public void onFailure(Throwable caught) {
		if(caught instanceof StatusCodeException){
			if(((StatusCodeException)caught).getStatusCode()== Response.SC_UNAUTHORIZED ){
				// SHOW_LOGON_DIALOG;
				return;
			}
		}	
		MessageHandler.get().show(caught);
		((Status)Registry.get("status")).clearStatus("")  ;
		caught.printStackTrace();  
	}

	 
	public void onSuccess(T result) { 
		MessageHandler.get().show("---"); 
	}
  

}
